<?php
class user{
  public $user;
  public $pswd;
}

$user=new User();
$user->user='litong';
$user->pswd='123456';

$jsonString=json_encode($user);
echo $jsonString;

//将jsonString转为字符串
$jsonString="{\"user\":\"litong\",\"pswd\":\"123456\"}";
$user1=json_decode($jsonString);
var_dump($user1);
echo $user1->user;
echo $user1->pswd;
